{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
    {% if letter_head and not no_letterhead %}
    <div class="letter-head">{{ letter_head }}</div>
    {% endif %}
    {%- if doc.meta.is_submittable and doc.docstatus==0-%}
    <div class="alert alert-info text-center">
        <h4 style="margin: 0px;">{{ _("DRAFT") }}</h4></div>
    {%- endif -%}
    {%- if doc.meta.is_submittable and doc.docstatus==2-%}
    <div class="alert alert-danger text-center">
        <h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
    {%- endif -%}
    {% if max_pages > 1 %}
    <p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
    {% endif %}
{%- endmacro -%}

{{ add_header(0,1,doc,letter_head, no_letterhead) }}


<div class="print-heading">
        <h2>Delivery Note<br>
            <small>{{ doc.name or ''}}</small>
        </h2>
</div>
<div class="row">        
     <div class="col-xs-6">            
        <div class="row">
            <div class="col-xs-5 text-right"><label>Customer Name</label></div>
            <div class="col-xs-7 ">{{ doc.customer }} </div>
        </div>
        {%- if doc.address_display -%}
        <div class="row">
            <div class="col-xs-5 text-right"><label>Address</label></div>
            <div class="col-xs-7 ">{{ doc.address_display or ''}}</div>
        </div>         
        {%- endif -%}

    </div>

    <div class="col-xs-6">
        <div class="row">
            <div class="col-xs-5 text-right"> <label>Date</label> </div>
            <div class="col-xs-7 ">
                {{ doc.get_formatted("posting_date") or ''}}</div>
        </div>    
    </div>
            
</div>
        
<br>

<table class="table table-condensed table-hover table-bordered">
        <tr>
            <th>Sr</th>
            <th>Description</th>
            <th class="text-right">Pieces </th>
        </tr>
        {%- for row in doc.items -%}
        <tr>
            <td style="width: 10%;">{{ row.idx }}</td>
            <td style="width: 70%;">
    {% if row.in_format_data("image") and row.get("image") -%}
<div class="pull-left" style="max-width: 20%; margin-right: 10px;">
    <img src="{{ row.image }}" style="max-width: 100%">
</div>
{%- endif %}

                 <b>{{ row.item_code or '' }} </b><br> 
                 {{ row.description or '' }}  </td>
            <td style="width: 20%; text-align: right;">{{ row.qty }}</td>
        </tr>
        {%- endfor -%}
    </tbody>
</table>
<br>
   
<div class="row">
 <div class="col-xs-12 text-left">{{ doc.terms or '' }}</div>
</div>
